import http from '@/utils/http'
import type {SettlementDashboardOverviewCommonResp} from "@/apis/settlement/earnings";

const BASE_URL = '/musician/musicianBind'

export interface MusicianBindResp {
    id: string
    userName: string
    artist: string
    updateTime: string
    createUserString: string
    updateUserString: string
    disabled: boolean
}

export interface MusicianBindDetailResp {
    id: string
    userName: string
    artist: string
    isBind: string
    createUser: string
    createTime: string
    updateUser: string
    updateTime: string
    notes: string
    url: string
    createUserString: string
    updateUserString: string
}

export interface MusicianBindQuery {
    artist: string | undefined
    notes: string | undefined
    userName: string | undefined
    isBind: string | undefined
    sort: Array<string>
}

export interface MusicianBindPageQuery extends MusicianBindQuery, PageQuery {
    createUser: string | undefined
}

/** @desc 查询音乐人绑定列表 */
export function listMusicianBind(query: MusicianBindPageQuery) {
    return http.get<PageRes<MusicianBindResp[]>>(BASE_URL, query)
}

/** @desc 查询音乐人绑定列表 */
export function getMusicianBindByUserId(id: string, query: MusicianBindPageQuery) {
    // query.createUser = id
    // query.userName = id
    return http.get<PageRes<MusicianBindResp[]>>(`${BASE_URL}/getMusicianBindByUserId/${id}`, query);
    // return http.get<PageRes<MusicianBindResp[]>>(`${BASE_URL}/getMusicianBindByUserId`, query);
}

/** @desc 查询音乐人绑定详情 */
export function getMusicianBind(id: string) {
    return http.get<MusicianBindDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增音乐人绑定 */
export function addMusicianBind(data: any) {
    return http.post(BASE_URL, data)
}

/** @desc 修改音乐人绑定 */
export function updateMusicianBind(data: any, id: string) {
    return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 修改音乐人绑定 */
export function updateMusicianBindByArtists(data: Array<string>) {
    return http.put(`${BASE_URL}/updateStatus`, data)
}
/** @desc 删除已经创建未绑定的艺人 */
export function deleteMusicianBindByArtists(data: Array<string>) {
    return http.put(`${BASE_URL}/deleteUnBind`, data)
}

/** @desc 删除音乐人绑定 */
export function deleteMusicianBind(id: string) {
    return http.del(BASE_URL, {ids: [id]})
}

/** @desc 导出音乐人绑定 */
export function exportMusicianBind(query: MusicianBindQuery) {
    return http.download(`${BASE_URL}/export`, query)
}
